from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker
from pyecharts.commons.utils import JsCode

Bar().set_colors(['red','orange','yellow','blue'])

c = (
    Bar()
    .add_xaxis(['牛顿','欧拉','费马','阿基米德'])
    .add_yaxis("红色预警",[5,4,3,7],stack="stack1",itemstyle_opts=opts.ItemStyleOpts(color='#EE6666'))
    .add_yaxis("橙色预警", [4,8,3,10],stack="stack1",itemstyle_opts=opts.ItemStyleOpts(color='#FAC858'))
    .add_yaxis("绿色预警", [2, 3, 4, 6],stack="stack1", itemstyle_opts=opts.ItemStyleOpts(color='#84B76C'))
    .add_yaxis("蓝色预警", [4, 8, 3, 10], stack="stack1", itemstyle_opts=opts.ItemStyleOpts(color='#5470C6'))
    .reversal_axis()
    .set_series_opts(label_opts=opts.LabelOpts(is_show=True,position="inside",color= 'black'))
    .set_global_opts(title_opts=opts.TitleOpts(title="数学大师启示录"),
                    xaxis_opts=opts.AxisOpts(name='预警数',
                    axistick_opts=opts.AxisTickOpts(is_show=False)),
                    yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True),name='欧洲一流数学家'),
                     )
    .render("bar_reversal_axis.html")
)